package com.lj.message;

import cn.hutool.core.util.ClassUtil;
import com.lj.common.module.ModuleInfo;
import com.lj.sse.SseAutoConfiguration;
import io.swagger.v3.oas.annotations.Operation;
import org.mybatis.spring.annotation.MapperScan;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @author luojing
 * @since 2025/10/15 18:38
 */
@Configuration
@ComponentScan("com.lj.message")
@MapperScan("com.lj.message.mapper")
public class MessageAutoConfiguration {

    @Bean
    public ModuleInfo messageModuleInfo() {
        return new ModuleInfo().setModuleName("message");
    }

    @Bean
    public GroupedOpenApi messageApi() {
        // 创建了一个api接口的分组
        return GroupedOpenApi.builder()
                .group("message")
                .displayName("message模块")
                .packagesToScan(ClassUtil.getPackage(SseAutoConfiguration.class) + ".controller")
                .addOpenApiMethodFilter(method -> method.isAnnotationPresent(Operation.class))
                .build();
    }
}